package com.example.springevent.ivd.domain;

import java.util.Objects;

public class InvoiceKey implements Comparable<InvoiceKey> {
	private String invoiceCode;
	private String invoiceNo;

	public static InvoiceKey of(InvoiceVerifyDetail ivd) {
		return new InvoiceKey(ivd.getInvoiceCode(), ivd.getInvoiceNo());
	}

	public InvoiceKey() {
		super();
	}

	public InvoiceKey(String invoiceCode, String invoiceNo) {
		super();
		this.invoiceCode = invoiceCode;
		this.invoiceNo = invoiceNo;
	}

	public String getInvoiceCode() {
		return invoiceCode;
	}

	public void setInvoiceCode(String invoiceCode) {
		this.invoiceCode = invoiceCode;
	}

	public String getInvoiceNo() {
		return invoiceNo;
	}

	public void setInvoiceNo(String invoiceNo) {
		this.invoiceNo = invoiceNo;
	}

	@Override
	public int hashCode() {
		return Objects.hash(invoiceCode, invoiceNo);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		InvoiceKey other = (InvoiceKey) obj;
		return Objects.equals(invoiceCode, other.invoiceCode) && Objects.equals(invoiceNo, other.invoiceNo);
	}

	@Override
	public String toString() {
		return "InvoiceKey [invoiceCode=" + invoiceCode + ", invoiceNo=" + invoiceNo + "]";
	}

	@Override
	public int compareTo(InvoiceKey t2) {
		int compareTo = t2.getInvoiceCode().compareTo(this.invoiceCode);
		return compareTo == 0 ? t2.getInvoiceNo().compareTo(this.invoiceNo) : compareTo;
	}

}
